<template>
	<view :class="[primarySize()]">
		<view class="container bg-white">
			<view class="pb30">
				<template v-for="(item,index) in resumeDateList">
				<view class="date_info">{{item}}</view>
				<view class="plr30 pb30">
					<resume-list :resumes="resumeDateMapList[item]"></resume-list>
				</view>
					
				</template>
				<view class="nothing" v-if="resumeListMore.nothing">
					<image src="https://admin.mosizp.cn/static/public/icon_nothing.png" mode="aspectFit"></image>
					<text>暂无人才数据</text>
				</view>
				<view class="g-btn3-wrap" v-else>
					<view class="g-btn3" @click="fetchResume()">{{resumeListMore.text}}</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	import resumeList from '../../components/resume-list/resume-list.vue';
	export default {
		components: {
			resumeList
		},
		data() {
			return {
				resumeList: [],
				resumeDateList: [],
				resumeDateMapList: {},
				resumeListMore: {
					page: 1
				},
			}
		},
		onReady() {
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: this.primaryColor()
			})
		},
		onLoad() {

			let userinfo = this.$core.getUserinfo();
			this.userinfo = userinfo;
			this.fetchResume();
		},
		onReachBottom() {
			this.fetchResume();
		},
		methods: {
			fetchResume() {
				this.$util.fetch(this, 'xilujob.resume/look_my', {}, 'resumeListMore', 'resumeList', 'data', list => {
					list.data.forEach(resume => {
						if (!resume.personal.realname && resume.job_intention.length <= 0) {
							return;
						}
						let viewDate = this.$util.formatDatetime(resume.view_time, 'yyyy年m月d日');
						if (this.resumeDateList.indexOf(viewDate) === -1) {
							this.resumeDateList.push(viewDate);
						}
						resume.job_intention = resume.job_intention.length > 0 ? resume.job_intention[0] :
							null;
						let resumeList = this.resumeDateMapList[viewDate] || [];
						resumeList.push(resume);
						this.$set(this.resumeDateMapList, viewDate, resumeList)


					});
					return [];
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.recomd_item {
		padding: 25rpx 30rpx 20rpx;
		width: 690rpx;
		background: #FFFFFF;
		border-radius: 18rpx;
		margin-top: 20rpx;

		.label {
			display: inline-block;
			vertical-align: top;
			height: 38rpx;
			background: #F7F7F7;
			border-radius: 4rpx;
			line-height: 38rpx;
			text-align: center;
			font-size: 20rpx;
			color: #A5A5A5;
			padding: 0 14rpx;
			margin-top: 20rpx;
			margin-right: 18rpx;
		}

		.bt {
			border-top: 1px solid #eee;
		}
	}
	.date_info {
		line-height: 60rpx;
		background-color: #F4F4F4;
		font-size: 24rpx;
		color: #999999;
		padding: 0 30rpx;
	}
</style>